<?php

namespace common\models\shop;

use Yii;

/**
 * This is the model class for table "shop_dispatch".
 *
 * @property integer $id
 * @property string $dispatchname
 * @property integer $dispatchtype
 * @property integer $displayorder
 * @property string $firstprice
 * @property string $secondprice
 * @property integer $firstweight
 * @property integer $secondweight
 * @property integer $express
 * @property string $description
 */
class ShopDispatch extends \yii\db\ActiveRecord
{


    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '配送方式',      //用于修改了什么的显示
        'mainfield' => 'dispatchname',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];


    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shop_dispatch';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['dispatchtype', 'displayorder', 'firstweight', 'secondweight', 'express'], 'integer'],
            [['firstprice', 'secondprice'], 'number'],
            [['description'], 'string'],
            [['dispatchname'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'dispatchname' => '配送方式名称',
            'dispatchtype' => '配送类型',
            'displayorder' => '排序',
            'firstprice' => '首重价格',
            'secondprice' => '续重价格',
            'firstweight' => '首重重量',
            'secondweight' => '续重重量',
            'express' => '物流公司',
            'description' => '简单介绍',
        ];
    }


    /**
     * @return \yii\db\ActiveQuery
     * 获取快递公司
     */
    public function getExpress()
    {
        return $this->hasOne(ShopDispatch::className(),['id'=>'express']);
    }


    public static function allData()
    {
        return self::find()->select('*')->asArray()->all();
    }



}
